package com.SDR;

import com.SDR.Dao.Impl.IpRedisDaoImpl;
import com.SDR.Dao.Impl.UserRedisDaoImpl;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.io.Serializable;

/**
 * Created by Yoey on 2017/6/26.
 * extension : 通过接口加强了拓展性
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations ={"classpath:applicationContext.xml"})
public class TestSDR2 {
    @Autowired
    private RedisTemplate<String,Serializable> redisTemplate;

    @Autowired
    private IpRedisDaoImpl ipRedisDaoImpl;
    @Autowired
    private UserRedisDaoImpl userRedisDaoImpl;

    @Test
    public void  test1(){
        ipRedisDaoImpl.setIntoRedis("127.0.0.1","南京");
    }
    @Test
    public void  test2(){
        System.out.println(ipRedisDaoImpl.getFromRedis("127.0.0.1"));
        System.out.println(ipRedisDaoImpl.getFromRedis("UserBySer"));
    }

    //---------------------
    @Test
    public void  test3(){
        User user=new User("zyl","123",123.12);
        userRedisDaoImpl.setIntoRedis("",user);
    }
    @Test
    public void  test4(){
        System.out.println(ipRedisDaoImpl.getFromRedis("zyl"));
    }
}
